﻿/////////////////////////////////////////////////////////////////////
//
//	Map_FVG C# Class Library.
//
//	Print2
//	
//
//	autore: Gustavo Mainardi 
//	versione: 1.0
//	data: 01/12/2015
//
//
//	Cronologia delle versioni:
//
//	Versione 1.0 01/12/2015
//		versione originale
//
//////////////////////////////////////////////////////////////////////////
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Globalization;

namespace Map_Fvg
{
    public partial class Print 
    {

        static public int Xorig;
        static public int Yorig;
        static public float scalaX;
        static public float scalaY;

        private Graphics dc0;

        void drawMap(PrintPageEventArgs ev)
        {
            if (ViewQ.readViewQ == 0) return;
            char[] delimiterChars0 = { ',', '/' };
            string[] words;

            Graphics dc = ev.Graphics;
            dc0 = dc;

            dc.PageUnit = GraphicsUnit.Millimeter;
            NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;


            int Xdiff = ViewQ.Xmax - ViewQ.Xmin;
            int Ydiff = ViewQ.Ymax - ViewQ.Ymin;

            float scala = 1000.0F / float.Parse(this.textBox1.Text);
            scalaX = scala;
            scalaY = -scala;

            //      intestazione

            string line = string.Empty;
            Font printFont = new Font("Arial", 15);
            float yPos = 0;
            float leftMargin = 0;

            if (ViewQ.noFilesSelected == 1)
            {
                line = FormIniz.nameElement;
                line = string.Concat(line, "   ", ViewQ.IDtavol);

            }
            else
            {
                int iElem = 0;
                for (int i = 0; i < 4; ++i)
                {
                    string ss = UnioneDialog.fileUnione[i];
                    if (ss != string.Empty)
                    {
                        if (iElem > 0) line = string.Concat(line, " / ");
                        line = string.Concat(line, ss.Trim());
                        ++iElem;
                        if (iElem == ViewQ.noFilesSelected) break;
                    }
                }
            }

            yPos = 5;
            leftMargin = 60;
            if (!bLandscape) leftMargin = 20;

            dc.DrawString(line, printFont, Brushes.Black, leftMargin, yPos);

            line = "scala  1:";
            line = string.Concat(line, textBox1.Text);
            leftMargin = 190;
            if (!bLandscape) leftMargin = 130;
            ++yPos;
            printFont = new Font("Arial", 12);
            dc.DrawString(line, printFont, Brushes.Black, leftMargin, yPos);

            line = initX.ToString();
            string s3 = (initX + width1).ToString();
            string s5 = (initY + height1).ToString();
            line = string.Concat(line, " / ", initY.ToString(), " - ", s3, " / ", s5);
            leftMargin = 240;
            if (!bLandscape) leftMargin = 170;
            //           yPos += 2;
            printFont = new Font("Arial", 10);
            dc.DrawString(line, printFont, Brushes.Black, leftMargin, yPos);

            //      cornice          

            float fshiftX = 2.5F;
            float fshiftY = 1;
            double angleRad = -ViewQ.alpha * Math.PI / 180.0D; // 0F;

            float initXX = initX - fshiftX;
            float initYY = initY - fshiftY;
            float XX = (float)((double)initXX * Math.Cos(angleRad) - (double)initYY * Math.Sin(angleRad)); // -ViewQ.Xoff;
            float YY = (float)((double)initXX * Math.Sin(angleRad) + (double)initYY * Math.Cos(angleRad));  // -ViewQ.Yoff;

            float Xoff = XX * (orizz - shiftX) / width1;
            float Yoff = YY * (ivert - shiftY) / height1;

            Xorig = 3 - (int)Xoff; ;
            Yorig = (int)(scala * Ydiff - Yoff) + 20;


            Pen blackPen = new Pen(Color.Black);
            blackPen.Width = 0.5F;

            RectangleF[] rects = { new RectangleF(18, 18, (float)orizz - shiftX, (float)ivert - shiftY) };
            dc.DrawRectangles(blackPen, rects);

            RectangleF Border = rects[0];
            dc.Clip = new Region(Border);

            //
            //      linea_shp
            //
            dc.RotateTransform(ViewQ.alpha);
            Scarpata scr = new Scarpata();

            for (int i = 0; i < ViewQ.nShapes; ++i)  //    nShapes; ++i)
            {
                int nVertices = ViewQ.vectShapes[i].nVertices;
                int ipnt = ViewQ.vectShapes[i].pntpL;
                int pntSimb = ViewQ.vectShapes[i].pntSimb;
                if (ViewQ.vectS[pntSimb].selected == 0) continue;
                int visib = ViewQ.vectS[pntSimb].visib;
                if (visib == 0) continue;

                Color icolor = ViewQ.vectS[pntSimb].icolor;
                Pen iPen = new Pen(icolor);

                string ss = ViewQ.vectS[pntSimb].tratto;
                int type = ViewQ.vectS[pntSimb].penType;

                float width = 0F;
                float interpasso = 0F;
                string s1;
                float[] dashValues = { 0, 0 };
                float diam = 0;

                //               Scarpata scr = new Scarpata();

                switch (type)
                {
                    case 1:
                        int ipos = ss.IndexOf('/');
                        int len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        width = float.Parse(s1, nfi);
                        break;
                    case 11:            // scarpata (ciglio)
                    case 12:            // scarpata (piede)
                    case 13:            // scarpata rivestita (ciglio)
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        dashValues[0] = float.Parse(words[0], nfi);
                        dashValues[1] = float.Parse(words[1], nfi);
                        interpasso = float.Parse(words[2], nfi);
                        width = float.Parse(words[3], nfi);
                        break;
                    case 26:         //  limite di bosco
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        width = float.Parse(words[4], nfi);
                        dashValues[0] = float.Parse(words[0], nfi); // / width;
                        dashValues[1] = float.Parse(words[1], nfi); // / width;
                        diam = float.Parse(words[2], nfi);
                        interpasso = float.Parse(words[3], nfi);
                        break;
                    case 33:        //  ruderi
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        dashValues[0] = float.Parse(words[0], nfi);
                        dashValues[1] = float.Parse(words[1], nfi);
                        width = float.Parse(words[2], nfi);
                        break;
                    case 38:            //  limite di comune
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        width = float.Parse(words[2], nfi);
                        diam = float.Parse(words[0], nfi);
                        interpasso = float.Parse(words[1], nfi);
                        break;
                    case 40:         //  curva di livello intermedia
                    case 41:         //  curva di livello direttrice
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        width = float.Parse(s1, nfi);
                        break;
                    case 42:     //  sentieri CAI
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        width = float.Parse(s1, nfi);
                        dashValues[0] = 0F;
                        break;
                    case 43:        //  sentieri
                    case 44:        //  bordo di rotabile
                    case 60:        //  tracce sentieri
                        ipos = ss.IndexOf('/');
                        len = ss.Length;
                        ++ipos;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        width = float.Parse(words[2], nfi);
                        dashValues[0] = float.Parse(words[0], nfi);
                        dashValues[1] = float.Parse(words[1], nfi);
                        break;
                    default:
                        width = 0F;
                        break;
                }
                if (width == 0F) continue;

                iPen.Width = width;
                if (type != 12 && dashValues[0] > 0F) iPen.DashPattern = dashValues;

                PointF[] polygon = new PointF[nVertices];
                for (int j = 0; j < nVertices; ++j)
                {
                    polygon[j].X = (ViewQ.PL[ipnt].X - ViewQ.Xmin) * scalaX + Xorig;
                    polygon[j].Y = (ViewQ.PL[ipnt].Y - ViewQ.Ymin) * scalaY + Yorig;
                    ++ipnt;
                }
                if (type == 11 || type == 12 || type == 13)
                {
                    scr.scarpata(iPen, polygon, width, dashValues[0], dashValues[1], interpasso, dc, i, type);
                }
                else if (type == 38)
                {
                    dashValues[0] = diam;
                    dashValues[1] = interpasso - diam;
                    iPen.DashPattern = dashValues;
                    dc.DrawCurve(iPen, polygon);
                }
                else dc.DrawCurve(iPen, polygon);

                if (type == 26 && diam > 0)        //  limite di bosco
                {
                    scr.limiteDiBosco(iPen, polygon, width, dashValues[0], dashValues[1], interpasso, diam, dc, i);
                }
            }

            //        tracciamento reticolo

            float X0, Y0, X1, Y1;
            blackPen.Width = 0.2F;
            Font printFont1 = new Font("Arial", 9);

            for (int i = 0; i < 20; ++i)
            {
                if (ViewQ.retic[i].X == 0) break;
                X0 = (ViewQ.retic[i].X - ViewQ.Xmin) * scalaX + Xorig;
                if (X0 < 13 || X0 > orizz - 7) continue;
                Y0 = (ViewQ.vert[0].Y - ViewQ.Ymin) * scalaY + Yorig;
                X1 = X0;
                Y1 = (ViewQ.vert[1].Y - ViewQ.Ymin) * scalaY + Yorig;
                dc.DrawLine(blackPen, X0, Y0, X1, Y1);
            }

            for (int i = 0; i < 20; ++i)
            {
                if (ViewQ.retic[i].Y == 0) break;
                Y0 = (ViewQ.retic[i].Y - ViewQ.Ymin) * scalaY + Yorig;
                if (Y0 < 10 || Y0 > ivert) continue;       
                X0 = 10;  
                X1 = orizz - 7;  
                Y1 = Y0;

                dc.DrawLine(blackPen, X0, Y0, X1, Y1);
            }

            dc.ResetTransform();

            Rectangle rect2 = new Rectangle(5, 0, orizz - 22, ivert);
            dc.Clip = new Region(rect2);
            //
            //  asse orizzontale
            //
            for (int i = 0; i < 20; ++i)
            {
                if (ViewQ.retic[i].X == 0) break;
                X0 = (ViewQ.retic[i].X - ViewQ.Xmin) * scalaX + Xorig;
                if (X0 < 13 || X0 > 280) continue;
                string ss = ViewQ.retic[i].X.ToString();
                int length = ss.Length;
                line = ss.Substring(2, length - 2);
                float xrot = (ViewQ.vert[1].X - ViewQ.vert[0].X) * scalaX;
                SizeF stringSize = new SizeF();
                stringSize = dc.MeasureString(line, printFont1);
                float XX0 = X0 - stringSize.Width / 2; 
                XX0 = X0;
                Y0 = ivert - 8; 

                dc.DrawString(line, printFont1, Brushes.Black, XX0, Y0);
            }

            for (int i = 0; i < 20; ++i)
            {
                //
                //  asse verticale
                //
                if (ViewQ.retic[i].Y == 0) break;
                Y0 = (ViewQ.retic[i].Y - ViewQ.Ymin) * scalaY + Yorig;
                if (Y0 < 13 || Y0 > ivert - 10) continue;
                X0 = 7; 
                X1 = orizz - 8;  
                Y1 = Y0;

                float yrot = (ViewQ.vert[2].Y - ViewQ.vert[1].Y) * scalaY;

                string ss = ViewQ.retic[i].Y.ToString();
                int length = ss.Length;
                line = ss.Substring(2, length - 2);
                X0 = 9;
                SizeF stringSize = new SizeF();
                stringSize = dc.MeasureString(line, printFont1);
                float YY0 = Y0 + stringSize.Width / 2;

                float angle = -90.0F;
                dc.TranslateTransform(X0, YY0);
                dc.RotateTransform(angle);

                dc.DrawString(line, printFont1, Brushes.Black, 0, 0);
                //         MessageBox.Show(line + "  " + X0.ToString() + "  " + Y0.ToString() + "  " + X1.ToString());

                dc.ResetTransform();
            }


            //
            //      text_shp
            //

            Rectangle rect3 = new Rectangle(18, 18, orizz - shiftX, ivert - shiftY);
            dc.Clip = new Region(rect3);
            dc.RotateTransform(ViewQ.alpha);

            float rapp = 1.0F;
            if (scala != 0.2F)
            {
                rapp = scala / 0.2F;
            }

            for (int i = 0; i < ViewQ.nShapesT; ++i)  //    nShapesT; ++i)
            {

                int pntSimb = ViewQ.vectShapesT[i].pntSimb;

                if (ViewQ.vectT[pntSimb].selected == 0) continue;

                int visib = ViewQ.vectT[pntSimb].visib;
                if (visib == 0) continue;

                Color icolor = ViewQ.vectT[pntSimb].icolor;
                SolidBrush iBrush = new SolidBrush(icolor);
                SolidBrush iBrush1 = new SolidBrush(Color.White);
                Font iFont = ViewQ.vectT[pntSimb].iFont;
                float angle = ViewQ.vectShapesT[i].GMrotation;
                bool bAngle = false;
                if (angle != 0.0F)
                {
                    bAngle = true;
                }

                Point Pnt = new Point();
                string stx = ViewQ.vectShapesT[i].testo.Trim();

                char[] charArr = stx.ToCharArray();
                int icar = 0;
                bool flag = true;
                foreach (char ch in charArr)
                {
                    if (flag && ch == ' ')
                    {
                        ++icar;
                        flag = false;
                    }
                    if (ch != ' ') flag = true;
                }

                Pnt.X = (int)((ViewQ.vectShapesT[i].XX.X - ViewQ.Xmin) * scalaX) + Xorig;
                Pnt.Y = (int)((ViewQ.vectShapesT[i].XX.Y - ViewQ.Ymin) * scalaY) + Yorig;
                string space = " ";
                float fspace = dc.MeasureString(space, iFont).Width;

                int ipt = 0;
                int ncar = 0;
                int len = charArr.Length;
                for (int ii = 0; ii < icar + 1; ++ii)
                {
                    string sty = string.Empty;

                    if (icar == 0)
                    {
                        string stz = new string(charArr);
                        sty = stz;
                    }

                    if (icar > 0)
                    {
                        int j;
                        for (j = ipt; j < len; ++j) if (charArr[j] == ' ') break;
                        int len1 = j - ipt;
                        ncar = 1;
                        char[] charArr2 = new char[len1];
                        for (int k = 0; k < len1; ++k) charArr2[k] = charArr[k + ipt];
                        ipt = j + 1;
                        string stz = new string(charArr2);
                        sty = stz;
                        while (ipt < len)
                        {
                            if (charArr[ipt] != ' ') break;
                            ++ipt;
                            ++ncar;
                        }
                    }

                    SizeF stringSize = new SizeF();
                    stringSize = dc.MeasureString(sty, iFont);
                    float width2 = dc.MeasureString(sty, iFont).Width;
                    float height2 = dc.MeasureString(sty, iFont).Height;
                    float XX0 = 0.1F * width2;
                    float YY0 = 0.6F * height2;
                    float XX1 = 0.8F * width2;
                    float YY1 = 0.8F * height2;

                    if (bAngle)
                    {

                        dc.TranslateTransform(Pnt.X, Pnt.Y);
                        dc.RotateTransform(-angle);
                        RectangleF drawRect = new RectangleF(0, -YY0, width2, YY1);
                        dc.FillRectangle(iBrush1, drawRect);
                        dc.DrawString(sty, iFont, iBrush, drawRect);
                        dc.ResetTransform();
                        dc.RotateTransform(ViewQ.alpha);
                        if (icar > 0)
                        {
                            double angleR = Math.PI * angle / 180.0;
                            Pnt.X += (int)((width2 + (float)ncar * fspace) * Math.Cos(angleR));
                            Pnt.Y -= (int)((width2 + (float)ncar * fspace) * Math.Sin(angleR));
                        }
                    }
                    else
                    {
                        RectangleF drawRect = new RectangleF(Pnt.X, Pnt.Y - YY0, width2, YY1);
                        dc.FillRectangle(iBrush1, drawRect);
                        dc.DrawString(sty, iFont, iBrush, drawRect);
                        if (icar > 0) Pnt.X += (int)(width2 + ncar * fspace);

                    }
                }
            }
                        
            dc.ResetTransform();

  //
  //      point_shp
  //
            rapp = 1.0F;
            if (scala != 0.2F)
            {
                rapp = scala /0.2F;
            }

            dc.RotateTransform(ViewQ.alpha);

            for (int i = 0; i < ViewQ.nShapesP; ++i)
            {
                if (ViewQ.vectShapesP[i].selected == 0) continue;
                if (ViewQ.vectShapesP[i].modifica == 2) continue;
                int pntSimb = ViewQ.vectShapesP[i].pntSimb;
                if (ViewQ.vectP[pntSimb].selected == 0) continue;
                int visib = ViewQ.vectP[pntSimb].visib;
                if (visib == 0) continue;
                string codex = ViewQ.vectP[pntSimb].codice;

                int codice = ViewQ.vectP[pntSimb].simbolo;
                if (codice == 0) continue;

                Color icolor = ViewQ.vectP[pntSimb].icolor;
                SolidBrush iBrush = new SolidBrush(icolor);
                Font iFont = ViewQ.vectP[pntSimb].iFont;
                float angle = -ViewQ.vectShapesP[i].GMrotation;
                bool bAngle = false;
                if (angle != 0.0F)
                {
                    bAngle = true;
                    angle += 90.0F;
                }
                //          Pen iPen = new Pen(icolor, width);
                PointF Pnt = new PointF();
                Pnt.X = ((ViewQ.vectShapesP[i].XX.X - ViewQ.Xmin) * scalaX) + Xorig;
                Pnt.Y = ((ViewQ.vectShapesP[i].XX.Y - ViewQ.Ymin) * scalaY) + Yorig;

                if (codice != 1)
                {
                    float width = 0;
                    float height = 0;
                    string fileName = ViewQ.vectP[pntSimb].fileName.Trim();
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        string fileX = FormIniz.bitmapFolder;
                        fileX = string.Concat(fileX, fileName);
                        string ss = ViewQ.vectP[pntSimb].paramSimb;
                        switch (codice)
                        {
                            case 5:         //  sorgente perenne
                            case 22:        //  pino, altra conifera
                            case 38:        //  pino mugo
                            case 39:        // faggio
                                int ipos = ss.IndexOf('/');
                                ++ipos;
                                int len = ss.Length;
                                string s1 = ss.Substring(ipos, len - ipos);
                                words = s1.Split(delimiterChars0);
                                width = float.Parse(words[0], nfi);
                                height = float.Parse(words[1], nfi);
                                break;
                        }

                        Image newImage = Image.FromFile(fileX);

                        Bitmap Logo = new Bitmap(newImage);
                        Logo.MakeTransparent(Logo.GetPixel(1, 1));
                        newImage = (Image)Logo;
                        width = rapp * width;
                        height = rapp * height;
                        if (bAngle)
                        {
                            dc.TranslateTransform(Pnt.X, Pnt.Y);
                            dc.RotateTransform(angle);
                            RectangleF destRect = new RectangleF(0, 0, width, height);
                            dc.DrawImage(newImage, destRect);
                            dc.ResetTransform();
                            dc.RotateTransform(ViewQ.alpha);
                        }
                        else
                        {
                            RectangleF destRect = new RectangleF(Pnt.X, Pnt.Y, width, height);
                            dc.DrawImage(newImage, destRect);
                        }
                        continue;
                    }
                }
                if (codice == 1)
                {
                    RectangleF pntR = new RectangleF(Pnt.X, Pnt.Y, 1, 1);
                    dc.DrawEllipse(blackPen, pntR);

                }
            }
                                                 
            dc.ResetTransform();
            

            //
            //      area_shp
            //
 
            dc.Clip = new Region(Border);

            dc.RotateTransform(ViewQ.alpha);

            for (int i = 0; i < ViewQ.nShapesA; ++i)
            {
                int nVertices = ViewQ.vectShapesA[i].nVertices;
                int ipnt = ViewQ.vectShapesA[i].pntPA;
                int nParts = ViewQ.vectShapesA[i].nParts;
                int[] ipart = new int[nParts + 1];
                if (nParts == 1)
                {
                    ipart[0] = 0;
                    ipart[1] = nVertices;
                }
                else
                {
                    string sp = ViewQ.vectShapesA[i].Parts_string;
                    words = sp.Split(delimiterChars0);
                    for (int j = 0; j < nParts; ++j) ipart[j] = int.Parse(words[j]);
                    ipart[nParts] = nVertices;
                }
                int pntSimb = ViewQ.vectShapesA[i].pntSimb;

                if (ViewQ.vectA[pntSimb].selected == 0) continue;
                int visib = ViewQ.vectA[pntSimb].visib;
                if (visib == 0) continue;

                string codice = ViewQ.vectA[pntSimb].codice;
                bool bEdif = false;
                if (codice.Contains("4A000ED")) bEdif = true;
                if (codice.Contains("4A000TE")) bEdif = true;
                if (codice.Contains("4A000IN")) bEdif = true;
                if (codice.Contains("4A000CU")) bEdif = true;
                if (codice.Contains("4A000AF")) bEdif = true;
                if (codice.Contains("4A000SM")) bEdif = true;
                if (codice.Contains("4A000BA")) bEdif = true;

                Color icolor = ViewQ.vectA[pntSimb].icolor;
                int type = ViewQ.vectA[pntSimb].codice_bordo;
                string ss = ViewQ.vectA[pntSimb].bordo;

                string s1;
                int ipos;
                int len;
                float[] dashValues = { 0, 0 };
                float dist_linee = 0;
                float offset = 0;
                float width = 0F;
                switch (type)
                {
                    case 1:
                        ipos = ss.IndexOf('/');
                        ++ipos;
                        len = ss.Length;
                        s1 = ss.Substring(ipos, len - ipos);
                        width = float.Parse(s1, nfi);
                        break;
                    case 5:
                        ipos = ss.IndexOf('/');
                        ++ipos;
                        len = ss.Length;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        width = float.Parse(words[2], nfi);
                        dashValues[0] = float.Parse(words[0], nfi);
                        dashValues[1] = float.Parse(words[1], nfi);
                        break;
                    default:
                        width = 0;
                        break;
                }

                if (width == 0F) continue;

                Pen iPen = new Pen(icolor, width);
                if (dashValues[0] > 0F) iPen.DashPattern = dashValues;


                Point[] polygon = new Point[1];

                for (int k = 0; k < nParts; ++k)
                {
                    ipnt = ViewQ.vectShapesA[i].pntPA + ipart[k];
                    int iVertices = ipart[k + 1] - ipart[k];
                    polygon = new Point[iVertices];
                    for (int j = 0; j < iVertices; ++j)
                    {
                        polygon[j].X = (int)((ViewQ.PA[ipnt].X - ViewQ.Xmin) * scalaX) + (int)Xorig;
                        polygon[j].Y = (int)((ViewQ.PA[ipnt].Y - ViewQ.Ymin) * scalaY) + (int)Yorig;
                        ++ipnt;
                    }
                    if (bEdif) dc.DrawLines(iPen, polygon);
                    else dc.DrawCurve(iPen, polygon);

                }

                type = ViewQ.vectA[pntSimb].codice_camp;
                if (type == 0) continue;
                ss = ViewQ.vectA[pntSimb].campitura;
                switch (type)
                {
                    case 1:
                        ipos = ss.IndexOf('/');
                        ++ipos;
                        len = ss.Length;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        width = float.Parse(words[2], nfi);
                        dashValues[0] = float.Parse(words[0], nfi);
                        dashValues[1] = float.Parse(words[1], nfi);
                        dist_linee = float.Parse(words[3], nfi);
                        offset = float.Parse(words[4], nfi);
                        iPen.Width = width;
                        if (nParts == 1) scr.arenile(dc, iPen, polygon, dashValues[0], dashValues[1], dist_linee, offset, i);
                        else
                        {
                            int mst = 1;
                            scr.arenile1(dc, iPen, nVertices, dashValues[0], dashValues[1], dist_linee, offset, i, mst);
                        }
                        break;

                    case 2:
                        ipos = ss.IndexOf('/');
                        ++ipos;
                        len = ss.Length;
                        s1 = ss.Substring(ipos, len - ipos);
                        words = s1.Split(delimiterChars0);
                        dashValues[0] = float.Parse(words[0], nfi);
                        dashValues[1] = float.Parse(words[1], nfi);
                        width = float.Parse(words[2], nfi);
                        offset = float.Parse(words[3], nfi);
                        dist_linee = float.Parse(words[4], nfi);
                        Pen mPen = new Pen(icolor, width);
                        int lst = 1;
                        scr.roccia(dc, mPen, nVertices, dashValues[0], dashValues[1], dist_linee, offset, i, lst);
                        break;

                    default:
                        width = 0;
                        break;
                }
            }
        }

    }
}
